From 3a7ad359e0573341ddd554446e7486a28824fb44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 10:29:31 +0000 Subject: [PATCH 001/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8bbbd8..24f7ce5 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.1.0", "@stdlib/ndarray-dtypes": "^0.1.0", "@stdlib/utils-keys": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 435d58b03b1d404c5bb4e5a5b59410d7400911e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 10:54:41 +0000 Subject: [PATCH 002/122] 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 | 41 +- benchmark/benchmark.js | 71 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 44 files changed, 6202 insertions(+), 4437 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c4e407..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -173,7 +166,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -235,11 +228,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8ce6b74..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index b6df5ea..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c7b478e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c8d45bb --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From ee14cd623d22bcdd8b8abc2f29558f752537a5bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:15:20 +0000 Subject: [PATCH 003/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6058dd6..baa6f68 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.1.0", "@stdlib/ndarray-dtypes": "^0.1.0", "@stdlib/utils-keys": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d076d98a41c5f9ac3fbec79b8d7ece71c81ff593 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:15:53 +0000 Subject: [PATCH 004/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6223 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c7b478e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From a111c2a519e4456a6957dc7b0f4ecb9499c9c3a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:16:44 +0000 Subject: [PATCH 005/122] 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 | 41 +- benchmark/benchmark.js | 71 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 44 files changed, 6202 insertions(+), 4445 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c4e407..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -173,7 +166,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -235,11 +228,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8ce6b74..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index b6df5ea..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c7b478e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..972f392 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 7909aa1bf09eccff55963c0419f619ec7267e33e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 14 Oct 2023 19:17:30 +0000 Subject: [PATCH 006/122] 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 2002f77..0554356 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@esm/index.mjs'; +import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@v0.1.0-esm/index.mjs'; ``` #### mostlySafeCasts( \[dtype] ) @@ -111,7 +111,7 @@ var out = mostlySafeCasts( 'foo' ); - - - - From 81b965d81fc33f094d7648274a51471132830070 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 15:34:44 +0000 Subject: [PATCH 010/122] 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 | 41 +- benchmark/benchmark.js | 71 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 6202 insertions(+), 4446 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 27b6c04..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T03:17:48.212Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c4e407..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -173,7 +166,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -235,11 +228,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8ce6b74..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index b6df5ea..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c7b478e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e7f1b72 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 1a9ec45bbc2ce5626e007a9a3084578a400b6aad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 13:26:55 +0000 Subject: [PATCH 011/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 05ddddc..73672d1 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.1.0", "@stdlib/ndarray-dtypes": "^0.1.0", "@stdlib/utils-keys": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ec88257fb6839bed76fac31d90408ebfb7b4dadb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:18:07 +0000 Subject: [PATCH 012/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6223 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c7b478e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 3f9ed8e86aff43c1526512997813537f0cf4a57a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:18:52 +0000 Subject: [PATCH 013/122] 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 | 43 +- benchmark/benchmark.js | 71 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 44 files changed, 6203 insertions(+), 4446 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c4e407..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -174,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -236,13 +229,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8ce6b74..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index b6df5ea..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c7b478e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a7ba3fb --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From fec01dd451bf72ef5e5dd87c1fa1ab8269bbdb56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 07:37:53 +0000 Subject: [PATCH 014/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 785ae55..2e41399 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.1.0", "@stdlib/ndarray-dtypes": "^0.1.0", "@stdlib/utils-keys": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e895b5cb001240f1090cd420649404c79b27ee6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 03:03:17 +0000 Subject: [PATCH 015/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6223 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c7b478e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From af9667915072ff74d83842074b6f5f77a1b05c01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 03:03:58 +0000 Subject: [PATCH 016/122] 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 | 43 +- benchmark/benchmark.js | 71 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 6203 insertions(+), 4442 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 704dc86..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T03:28:11.794Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c4e407..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -174,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -236,13 +229,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8ce6b74..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index b6df5ea..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c7b478e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5f70ab3 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From a2b943d20719685371e1b4299acbe608bacdf077 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:52:17 +0000 Subject: [PATCH 017/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 38d0ce8..f0ddc55 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.1.0", "@stdlib/ndarray-dtypes": "^0.1.0", "@stdlib/utils-keys": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 30ba67d992fa71653ea4f57a7c4f3ec395b794d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 11:13:07 +0000 Subject: [PATCH 018/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6223 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c7b478e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 20b14fca7257afb49fc53a7d5ee4535deb20f2df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 11:13:33 +0000 Subject: [PATCH 019/122] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 6203 insertions(+), 4448 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 fd79592..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T03:00:10.983Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c69d07..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -174,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -236,13 +229,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index b6df5ea..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cb432d5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e1893d8 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From a3b41e6292d86512a0242c0d08880cb960324a01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 05:22:42 +0000 Subject: [PATCH 020/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 38d0ce8..f0ddc55 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.1.0", "@stdlib/ndarray-dtypes": "^0.1.0", "@stdlib/utils-keys": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f56675933e843bd627cd69f5694582e82ebf63fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:42:53 +0000 Subject: [PATCH 021/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6223 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cb432d5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 102695a3a95fbbed0119bf20117df337ecd6f059 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:43:10 +0000 Subject: [PATCH 022/122] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 6203 insertions(+), 4453 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 a8584cb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T03:36:53.384Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 1c69d07..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cb432d5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8496d47 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From e6ba20b4bd9153c6c170457b6acb4fa9485cc7d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 09:44:43 +0000 Subject: [PATCH 023/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index de48568..a62b078 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.0", "@stdlib/ndarray-dtypes": "^0.2.0", "@stdlib/utils-keys": "^0.2.0", - "@stdlib/utils-library-manifest": "^0.2.0" + "@stdlib/utils-library-manifest": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.1.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0be53ccd43b69370d65430488c8c5b9aff2f5472 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 18:18:27 +0000 Subject: [PATCH 024/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6223 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cb432d5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 99f0b0596e5487aabcbf6cf3dc08ba420fe5267c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 18:18:47 +0000 Subject: [PATCH 025/122] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 6177 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 6203 insertions(+), 4456 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 db8b194..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9a04355 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.1.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7307e20 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 9cce4129475e013d8e5cf48386125cc16327b931 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:27:22 +0000 Subject: [PATCH 026/122] 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 33cad89..67e00c4 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@esm/index.mjs'; +import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@v0.2.0-esm/index.mjs'; ``` #### mostlySafeCasts( \[dtype] ) @@ -111,7 +111,7 @@ var out = mostlySafeCasts( 'foo' ); - - - - From 7ca4aef4ccad262019febe0316baa1567f43660c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:49:26 +0000 Subject: [PATCH 030/122] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 4868 insertions(+), 4450 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7530852 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.0-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fb97ac1 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From eb3512edc5902988dcf3e457e71acb9fd54b8c60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:17:00 +0000 Subject: [PATCH 031/122] 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 e7458ea..b250c63 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@esm/index.mjs'; +import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@v0.2.1-esm/index.mjs'; ``` #### mostlySafeCasts( \[dtype] ) @@ -111,7 +111,7 @@ var out = mostlySafeCasts( 'foo' ); - - - - From 2cb7a0983647840705db7008ec5cb52332871dbd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:26:12 +0000 Subject: [PATCH 035/122] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4452 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 3bf4337..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T03:31:19.705Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3fbb651 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4c9621 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 59a3a8dc9529ae8def44ae07dd81e3d04d178960 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 04:20:38 +0000 Subject: [PATCH 036/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 181c494..b59de64 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.1", "@stdlib/ndarray-dtypes": "^0.2.1", "@stdlib/utils-keys": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 084315a6b0ded0ea9e2844028c863c5ce20f7d8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 09:05:28 +0000 Subject: [PATCH 037/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3fbb651..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 86cea580204e935f403ff970f79dad7fea74a506 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 09:05:37 +0000 Subject: [PATCH 038/122] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4455 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 803c273..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:53:46.935Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3fbb651 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4c9621 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 782154ee86e52f939906f4dd374d31548ab63c8d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 00:33:26 +0000 Subject: [PATCH 039/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 181c494..b59de64 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.1", "@stdlib/ndarray-dtypes": "^0.2.1", "@stdlib/utils-keys": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1d73c0c43941837905a8b6575fed69a9be7f8bd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:46:26 +0000 Subject: [PATCH 040/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3fbb651..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 6e8026d5e875f0db84439b66479307b30aa4cc98 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:46:40 +0000 Subject: [PATCH 041/122] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 197 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 4868 insertions(+), 4456 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 135df33..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,s){s.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var g=p(function(A,v){ -var x=require('@stdlib/utils-keys/dist'),b=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,r,u,a,o,l,i,e;for(r={},t=x(f),n=t.length,e=0;e|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3fbb651 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4c9621 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 1f74482935ec54ae987710486606bad01ad77cef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 10 Jul 2024 21:14:57 +0000 Subject: [PATCH 042/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 181c494..b59de64 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.1", "@stdlib/ndarray-dtypes": "^0.2.1", "@stdlib/utils-keys": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.1", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3e910ea683f55600d1e718d8ae868c1538bf55b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 10 Jul 2024 21:15:26 +0000 Subject: [PATCH 043/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3fbb651..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var e,o={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}};function l(l){return 0===arguments.length?function(){var n,i,e,l,u,c,r,a,m;for(e={},i=(n=t(o)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 526bd1dfeb881876791ee5214818a69433054999 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 10 Jul 2024 21:15:48 +0000 Subject: [PATCH 044/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 105 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 4868 insertions(+), 4596 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 f92a6c5..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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..339dbf2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3971850 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 969e012adf3895a91de1ab64e48174a4cf6faf34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:58:00 +0000 Subject: [PATCH 045/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fc1769f..85f2921 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.1", "@stdlib/ndarray-dtypes": "^0.2.1", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3a9535270d90f04a932120b0c101aba18dbd10ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 02:01:30 +0000 Subject: [PATCH 046/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 339dbf2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 72336b966e6740f5cedd105ebf4f0cf5bbf8feea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 02:01:42 +0000 Subject: [PATCH 047/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 45 files changed, 4868 insertions(+), 4639 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cdda73b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0347b27 --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From befcb391db87cf49b89611e6634e90d74e78b76e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 02:05:49 +0000 Subject: [PATCH 048/122] Update README.md for ESM bundle v0.3.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27b7998..2af79d0 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@esm/index.mjs'; +import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@v0.3.0-esm/index.mjs'; ``` #### mostlySafeCasts( \[dtype] ) @@ -111,7 +111,7 @@ var out = mostlySafeCasts( 'foo' ); - - - - From 1282de8a8cbd6aa2bfcea4f7a691b293e96cf918 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 09:11:36 +0000 Subject: [PATCH 052/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 78 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4572 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 1b21d78..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T03:31:33.610Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From a4fb4901627008c0d9c36b42b43d5aeb43e85515 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:50:36 +0000 Subject: [PATCH 053/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8fdcb8305517d8e0ded3cae06850435501ad2a80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 23:04:16 +0000 Subject: [PATCH 054/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 5721a99d0146a7183211e41513c857f7051df716 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 23:04:28 +0000 Subject: [PATCH 055/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 1bdd793..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T18:43:40.876Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 2a1d7b3b3fd3ecc817e40e6fc26099477b708431 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 05:02:39 +0000 Subject: [PATCH 056/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2028860d3f07e0001ba08db7aa4b4ee4ff32ee79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 09:06:28 +0000 Subject: [PATCH 057/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From d055901ffe92ca93608c63c67d7bdf5539923f33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 09:06:39 +0000 Subject: [PATCH 058/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 0021bb2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:44:37.894Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 64d11802041410d03863be3b4df4fa8a3d500642 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 05:10:59 +0000 Subject: [PATCH 059/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b96ba13429aa0a01006ec22f8f7e883512fb0257 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:15:03 +0000 Subject: [PATCH 060/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 784377c8e077d8116a79636fa833a0ec5abae31d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:15:14 +0000 Subject: [PATCH 061/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 318e9cd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:54:37.049Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 49e7847c7903999cb78788a8c1559ccc77c975a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 05:07:33 +0000 Subject: [PATCH 062/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8f1ad840e1953a25a0f5bef1d4992439281c4773 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:44:19 +0000 Subject: [PATCH 063/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 9b03bde822edaf67dc701780bad89704b7485504 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:44:36 +0000 Subject: [PATCH 064/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 ab07097..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:58:10.026Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 60f9ab052a0a34777a28d69ca1fbd64c876cdc4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 05:23:09 +0000 Subject: [PATCH 065/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 467de37fd679b33c9117346abc110e291e7a2395 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 09:13:27 +0000 Subject: [PATCH 066/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 6a7b85e3d6f86e01955627b1566a77570136b689 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 09:13:40 +0000 Subject: [PATCH 067/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 4747 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 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 2a320e9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T04:03:05.494Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From e20efe7f95df14f033d0d609da7db502d717963f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:27:44 +0000 Subject: [PATCH 068/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 322b9a5e6edf922e6275309de3c7fe3fb44d26f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:42:22 +0000 Subject: [PATCH 069/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From f210af084669ff6dc878016716b36e389d4a39ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:42:36 +0000 Subject: [PATCH 070/122] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 4747 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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/.keepalive b/.github/.keepalive deleted file mode 100644 index ccf31f9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:56:46.002Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f25b6fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From e7a4b522c1e8965cb59226d6d5fd9c41d7a94641 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:26:05 +0000 Subject: [PATCH 071/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d68f855303732084a1377633de56f8de249dcec0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:54:50 +0000 Subject: [PATCH 072/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f25b6fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 647e9e3d4ee6e85ca9d04008ccabe5ce05a895e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:55:08 +0000 Subject: [PATCH 073/122] 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 | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 4746 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 9c900ba..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-03T01:12:05.491Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d4c164f..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..448e7ca --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 321f47e471bbc0664627e482b93dbd69ea5d4a47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:27:35 +0000 Subject: [PATCH 074/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 44e6efdddb920250718c3fb440cacd84b64ebe1d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:56:35 +0000 Subject: [PATCH 075/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 448e7ca..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From de729f0fa890219a6a5e04a1c9144f7958200410 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:56:50 +0000 Subject: [PATCH 076/122] 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 | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 4750 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 1b46fb6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T01:18:43.439Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..448e7ca --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From b58d45b871d1ac266a97b56315009359eefcde96 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:29:06 +0000 Subject: [PATCH 077/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7b268043a6f70481609afce3a7c920ee20d04dcf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:29:41 +0000 Subject: [PATCH 078/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 448e7ca..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From a43509119b51242e1605fe330c29bf82aed92fb1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:29:52 +0000 Subject: [PATCH 079/122] 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 | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 4750 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 ca0ca62..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T00:28:38.407Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..448e7ca --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 79cc373c2669a2f4e5eae3ec9e79818fff94aaaa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:53:00 +0000 Subject: [PATCH 080/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 74aa5da4f8aae612831891e3659dbbe37e567731 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:00:59 +0000 Subject: [PATCH 081/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 448e7ca..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From c6b415991fa928ff985fc0ffb0caef0503f8811c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:01:10 +0000 Subject: [PATCH 082/122] 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 | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 445 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 226 - lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 4750 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 94f4f9b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T00:51:19.429Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d02d782..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}}});var v=p(function(A,x){ -var b=require('@stdlib/utils-keys/dist'),s=require('@stdlib/assert-has-own-property/dist'),y=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),c;function h(){var t,n,e,l,r,u,a,i,o;for(e={},t=b(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index 5bcfba5..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..448e7ca --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a693a5c --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From abaea0086b0a9f7fa8d41f3191a3e01175d99741 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Jun 2025 06:55:24 +0000 Subject: [PATCH 083/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cec499c933d9ee2b76905f874a1bc6b81afd037b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Jun 2025 06:55:47 +0000 Subject: [PATCH 084/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 448e7ca..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,r,a,m;for(o={},i=(n=t(l)).length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 8467f9751d50ae06ab1c49d1ac8c613f92171f69 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Jun 2025 06:56:02 +0000 Subject: [PATCH 085/122] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 5026 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8074fe3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fa69aaa --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 23c6236ced1fba8f46bbb05550c64fd6df9dd6b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 02:34:40 +0000 Subject: [PATCH 086/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6dcc8f..a33dd01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 620b2e7b7ebf139e721e163de9834baa88d60b73 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 03:29:14 +0000 Subject: [PATCH 087/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8074fe3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From da147ed4030e20b31d93554f6b45ae859437e373 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 03:29:28 +0000 Subject: [PATCH 088/122] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 61 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 5027 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 2a7f68b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T02:08:02.824Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8074fe3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -81,9 +27,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fa69aaa --- /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 14b7c18..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From f193348d424d1ce79f4f79c2aaab63e2c8a34ad0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 06:25:09 +0000 Subject: [PATCH 089/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f7a2978..666219d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", "@stdlib/ndarray-dtypes": "^0.3.0", "@stdlib/utils-keys": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.3" + "@stdlib/utils-library-manifest": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.2", @@ -84,4 +85,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 41fe117d7286ba039a0590d6f7322e6061b11445 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 07:09:33 +0000 Subject: [PATCH 090/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8074fe3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From f73121df48140b298f642a142901ee692d1fcc8b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 07:09:57 +0000 Subject: [PATCH 091/122] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 206 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 5133 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3a90c4e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,4 +31,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fa69aaa --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From bebf735e1d8e651694950d1e99120c40a3535db8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 07:47:53 +0000 Subject: [PATCH 092/122] Update README.md for ESM bundle v0.4.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8226046..abbec02 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@esm/index.mjs'; +import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@v0.4.0-esm/index.mjs'; ``` #### mostlySafeCasts( \[dtype] ) @@ -111,7 +111,7 @@ var out = mostlySafeCasts( 'foo' ); - - - - From d8fe4349f41644c7ca7fa201276459fc91942fc7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 03:58:10 +0000 Subject: [PATCH 096/122] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 206 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 5134 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 f462f52..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-02T02:15:45.418Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3a90c4e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,4 +31,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fa69aaa --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From bd4c313fc027d79cc2b6a85804dfe6ceb6eb5961 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:32:22 +0000 Subject: [PATCH 097/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index baa048e..0ac6b7d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.0", "@stdlib/utils-keys": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.3" + "@stdlib/utils-library-manifest": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", @@ -84,4 +85,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3d3e93405d106f536d7a8446d71f00d5b6c76441 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:36:51 +0000 Subject: [PATCH 098/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3a90c4e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From b1680e2139274d96bc2de9de5e9ce3ee23200052 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:37:06 +0000 Subject: [PATCH 099/122] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 216 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4868 insertions(+), 5136 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,4 +31,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From f5817d8138d7d8ed6fd55b49f67feac50e4f5952 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:41:54 +0000 Subject: [PATCH 100/122] Update README.md for ESM bundle v0.4.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6deecd..40530ea 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@esm/index.mjs'; +import mostlySafeCasts from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-mostly-safe-casts@v0.4.1-esm/index.mjs'; ``` #### mostlySafeCasts( \[dtype] ) @@ -111,7 +111,7 @@ var out = mostlySafeCasts( 'foo' ); - - - - From bdcd667ad449696348f16c46d6db1edb517747ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:18:19 +0000 Subject: [PATCH 104/122] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 216 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 5137 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 1446500..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-09T00:59:16.059Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,4 +31,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From a09d287837e5f4312b780d5eed3d70e02fdc26e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 01:37:09 +0000 Subject: [PATCH 105/122] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 248cb95..38ea2a8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", "@stdlib/utils-keys": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.4" + "@stdlib/utils-library-manifest": "^0.2.4", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", @@ -84,4 +85,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3ac76dabf748ee9529b46dab67c39bfc3197ec4a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 02:20:25 +0000 Subject: [PATCH 106/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a93e6..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From 4dc1cb8fd7fbdb7a23ec5a7cf0f18e7134847371 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 02:20:46 +0000 Subject: [PATCH 107/122] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 216 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 71 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4868 insertions(+), 5137 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json 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 57c385b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-16T01:25:16.558Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 bc5d7e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,4 +31,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 5478fbb4bf9cc409bfc241735428917690d8f324 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Apr 2026 04:29:48 +0000 Subject: [PATCH 108/122] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98cb64a..e4ef73f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From 102375ea7b0b2ecc343baf580d76eb6f0470db14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Apr 2026 05:27:27 +0000 Subject: [PATCH 109/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a93e6..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From 9a7add21747eb033f576598a71448154372d742c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Apr 2026 05:27:42 +0000 Subject: [PATCH 110/122] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 250 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 72 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 46 files changed, 4867 insertions(+), 5181 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 c0a07ab..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::dtype', pkg ), function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 432dc94e240ca541f790f43f53a4508c2385b52f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Apr 2026 03:20:17 +0000 Subject: [PATCH 111/122] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98cb64a..e4ef73f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From c39809dd11f9d886bd2382b1a99fa728b4076ef3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Apr 2026 03:23:43 +0000 Subject: [PATCH 112/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a93e6..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From 0182c1dfc83488e68a3098ea6d99f06bbef1d54b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Apr 2026 03:24:03 +0000 Subject: [PATCH 113/122] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 250 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 72 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4867 insertions(+), 5187 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a91e386..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-27T03:18:59.188Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 c0a07ab..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::dtype', pkg ), function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 5133771396b8b0ff3f773d9c81e56c278003d4cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 5 Jun 2026 03:28:08 +0000 Subject: [PATCH 114/122] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98cb64a..e4ef73f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From 32c8e080cbe102de741babc13781fb577933bb93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 5 Jun 2026 03:45:01 +0000 Subject: [PATCH 115/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a93e6..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From b11ca27d8644b48245ed119d407316ea040c8f5c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 5 Jun 2026 03:45:20 +0000 Subject: [PATCH 116/122] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 250 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 72 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4867 insertions(+), 5200 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1a5cb2b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-05T03:24:56.375Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 c0a07ab..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::dtype', pkg ), function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 306bf6e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,l,e,u,a,c,i,o;for(l={},t=x(f),n=t.length,o=0;o|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From d154e166a216c8186ffe474aa95d6f18a4b30bfe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 16 Jul 2026 03:29:35 +0000 Subject: [PATCH 117/122] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98cb64a..e4ef73f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From 40f3e0e1102573e3710d7d131b610e0f01079068 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 16 Jul 2026 03:41:46 +0000 Subject: [PATCH 118/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a93e6..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From 27b2d71190117778bc95a7778051dca54d91c9e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 16 Jul 2026 03:42:02 +0000 Subject: [PATCH 119/122] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 250 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 72 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4867 insertions(+), 5200 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0678a66..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-16T03:24:09.640Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 c0a07ab..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::dtype', pkg ), function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 12c710b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){try{return n||t((n={exports:{}}).exports,n),n.exports}catch(i){throw (n=0, i)}};};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,i,e,u,a,c,o,l;for(i={},t=x(f),n=t.length,l=0;l|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); From 1c26334a4e590b90973f7d4eb8951a9111447f07 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Jul 2026 03:38:06 +0000 Subject: [PATCH 120/122] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98cb64a..e4ef73f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From cdad2d616c999e73acce5e9bc1d6cd84109350e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Jul 2026 03:54:12 +0000 Subject: [PATCH 121/122] Remove files --- index.d.ts | 41 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4888 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 10cd35f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an ndarray data type, the function returns a casting table. -* - If provided an unrecognized ndarray data type, the function returns `null`. -* -* @param dtype - ndarray data type value -* @returns list of ndarray data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a93e6..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f - - - - - - Rollup Visualizer - - - -
- - - - - From c0ca16f54790619ea3d1e7a216e2dc8d665f6348 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Jul 2026 03:54:34 +0000 Subject: [PATCH 122/122] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 250 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 72 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 27 - docs/types/test.ts | 34 - examples/index.js | 33 - include/stdlib/ndarray/mostly_safe_casts.h | 531 -- docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/data.json | 362 -- lib/index.js | 40 - lib/main.js | 135 - manifest.json | 38 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 75 - 47 files changed, 4867 insertions(+), 5200 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/mostly_safe_casts.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/data.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fd4bc8b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-21T03:28:31.761Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3ff60b8..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/mostly-safe-casts) 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 3df2845..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/mostly-safe-casts) 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 63de2c0..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 19 * * 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -176,7 +167,7 @@ for ( i = 0; i < DTYPES.length; 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]. @@ -241,13 +232,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes +[@stdlib/ndarray/casting-modes]: https://github.com/stdlib-js/ndarray-casting-modes/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts +[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray-safe-casts/tree/esm -[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts +[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray-same-kind-casts/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 c0a07ab..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::dtype', pkg ), function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e1068a..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/mostly-safe-casts" -%% click B href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/mostly-safe-casts -[production-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/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 e04880c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mostlySafeCasts from '../docs/types/index'; -export = mostlySafeCasts; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 12c710b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var p=function(t,n){return function(){try{return n||t((n={exports:{}}).exports,n),n.exports}catch(i){throw (n=0, i)}};};var m=p(function(S,g){g.exports={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}}});var v=p(function(A,b){ -var x=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-has-own-property/dist'),s=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=m(),r;function h(){var t,n,i,e,u,a,c,o,l;for(i={},t=x(f),n=t.length,l=0;l|null - ndarray data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 04f4878..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59a6c5a..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported ndarray data types: -var DTYPES = dtypes(); - -// Print the list of ndarray data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/include/stdlib/ndarray/mostly_safe_casts.h b/include/stdlib/ndarray/mostly_safe_casts.h deleted file mode 100644 index c0201b7..0000000 --- a/include/stdlib/ndarray/mostly_safe_casts.h +++ /dev/null @@ -1,531 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H -#define STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H - -#include "stdlib/ndarray/dtypes.h" -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 1, - [ STDLIB_NDARRAY_UINT8C ] = 1, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 1, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 1, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 1, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 1, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 1, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 1, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 1, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 1, - [ STDLIB_NDARRAY_FLOAT32 ] = 1, - [ STDLIB_NDARRAY_FLOAT64 ] = 1, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 1, - [ STDLIB_NDARRAY_COMPLEX64 ] = 1, - [ STDLIB_NDARRAY_COMPLEX128 ] = 1, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 1, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 1, - [ STDLIB_NDARRAY_GENERIC ] = 0 -}; - -const int8_t STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = 0, - [ STDLIB_NDARRAY_UINT8 ] = 0, - [ STDLIB_NDARRAY_UINT8C ] = 0, - [ STDLIB_NDARRAY_INT16 ] = 0, - [ STDLIB_NDARRAY_UINT16 ] = 0, - [ STDLIB_NDARRAY_INT32 ] = 0, - [ STDLIB_NDARRAY_UINT32 ] = 0, - [ STDLIB_NDARRAY_INT64 ] = 0, - [ STDLIB_NDARRAY_UINT64 ] = 0, - - [ STDLIB_NDARRAY_FLOAT16 ] = 0, - [ STDLIB_NDARRAY_FLOAT32 ] = 0, - [ STDLIB_NDARRAY_FLOAT64 ] = 0, - - [ STDLIB_NDARRAY_COMPLEX32 ] = 0, - [ STDLIB_NDARRAY_COMPLEX64 ] = 0, - [ STDLIB_NDARRAY_COMPLEX128 ] = 0, - - [ STDLIB_NDARRAY_BOOL ] = 0, - - [ STDLIB_NDARRAY_BINARY ] = 0, - [ STDLIB_NDARRAY_GENERIC ] = 1 -}; - -// Define a table of pointers containing the above casting tables: -const int8_t *STDLIB_NDARRAY_MOSTLY_SAFE_CASTS[ STDLIB_NDARRAY_NDTYPES ] = { - - [ STDLIB_NDARRAY_INT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT8, - [ STDLIB_NDARRAY_UINT8 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8, - [ STDLIB_NDARRAY_UINT8C ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT8C, - [ STDLIB_NDARRAY_INT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT16, - [ STDLIB_NDARRAY_UINT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT16, - [ STDLIB_NDARRAY_INT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT32, - [ STDLIB_NDARRAY_UINT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT32, - [ STDLIB_NDARRAY_INT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_INT64, - [ STDLIB_NDARRAY_UINT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_UINT64, - - [ STDLIB_NDARRAY_FLOAT16 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT16, - [ STDLIB_NDARRAY_FLOAT32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT32, - [ STDLIB_NDARRAY_FLOAT64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_FLOAT64, - - [ STDLIB_NDARRAY_COMPLEX32 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX32, - [ STDLIB_NDARRAY_COMPLEX64 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX64, - [ STDLIB_NDARRAY_COMPLEX128 ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_COMPLEX128, - - [ STDLIB_NDARRAY_BOOL ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BOOL, - - [ STDLIB_NDARRAY_BINARY ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_BINARY, - [ STDLIB_NDARRAY_GENERIC ] = STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_GENERIC -}; - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_MOSTLY_SAFE_CASTS_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a93e6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-keys@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";var o,l={float64:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float32:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},float16:{float64:1,float32:1,float16:1,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},int64:{float64:0,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},int32:{float64:1,float32:0,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},int16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:1,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},int8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:1,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint32:{float64:1,float32:0,float16:0,int64:1,int32:0,int16:0,int8:0,uint64:1,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,complex32:0,binary:0,generic:1,bool:0},uint16:{float64:1,float32:1,float16:0,int64:1,int32:1,int16:0,int8:0,uint64:1,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:0,binary:0,generic:1,bool:0},uint8:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},uint8c:{float64:1,float32:1,float16:1,int64:1,int32:1,int16:1,int8:0,uint64:1,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex128:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex64:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},complex32:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,complex32:1,binary:0,generic:1,bool:0},generic:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:0},binary:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:1,generic:0,bool:0},bool:{float64:0,float32:0,float16:0,int64:0,int32:0,int16:0,int8:0,uint64:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,complex32:0,binary:0,generic:1,bool:1}};function e(e){return 0===arguments.length?function(){var n,i,o,e,u,c,a,m,f;for(o={},i=(n=t(l)).length,f=0;f=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f5116a --- /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 4e3d003..0000000 --- a/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of ndarray data types to which a provided ndarray data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -});