From 197c1ac4c07f2cd4627397866f6cde4bbe23df89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 26 Mar 2023 10:21:19 +0000 Subject: [PATCH 001/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index adbfea6..8337421 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.0.8", "@stdlib/ndarray-base-shape2strides": "^0.0.8", "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From be40909678aef61f315e2d3acaae362b6e8c79de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 26 Mar 2023 10:23:59 +0000 Subject: [PATCH 002/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 458 -- 48 files changed, 6202 insertions(+), 5341 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index c9f83b0..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index cc66c0e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -151,7 +144,7 @@ for ( i = 0; i < dt.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]. @@ -211,9 +204,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 11ad5bd..d504479 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..085d3ea --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f41a233 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;8gBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 8337421..efbc8ba 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "github:stdlib-js/array-empty#main", - "@stdlib/buffer-alloc-unsafe": "^0.0.7", - "@stdlib/ndarray-base-ctor": "^0.0.6", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-dtypes": "^0.0.9", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..1b5f554 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 341849ad862047281292dbb05c85e302b56791a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:22:35 +0000 Subject: [PATCH 003/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3af9bd9..1385e90 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.0.8", "@stdlib/ndarray-base-shape2strides": "^0.0.8", "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e731167f45acfc448db8dc6204eb12afc3900400 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:23:06 +0000 Subject: [PATCH 004/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 d504479..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 085d3ea..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f41a233..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;8gBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1b5f554..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1594093de3fd620ffa0261701399051f316317bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:24:24 +0000 Subject: [PATCH 005/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 458 -- 48 files changed, 6202 insertions(+), 5341 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index c9f83b0..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index cc66c0e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -151,7 +144,7 @@ for ( i = 0; i < dt.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]. @@ -211,9 +204,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 11ad5bd..d504479 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..77a8af6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d1b5d0e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qhBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 1385e90..69694d8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.0.1", - "@stdlib/buffer-alloc-unsafe": "^0.0.7", - "@stdlib/ndarray-base-ctor": "^0.0.6", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-dtypes": "^0.0.9", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..488425a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 3da8de26818756c9f88f3bce2503759dd1f188d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:24:47 +0000 Subject: [PATCH 006/115] Update README.md for ESM bundle v0.0.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cea85e6..5a9eb15 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.0.1-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -97,7 +97,7 @@ The function accepts the following arguments: - - - - From 8c2a98bfd42f41be63c0d6533e277ba3b80782a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:39:18 +0000 Subject: [PATCH 010/115] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 458 -- 52 files changed, 6202 insertions(+), 5376 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index c9f83b0..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index cc66c0e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 88f4201..cfa4705 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e196c56 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.0.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index b32b5cf..36f601b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..26ab3da --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From ab1fd89fea3acd01480652eaf9e780fa6c716720 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:49:55 +0000 Subject: [PATCH 011/115] 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 4a69f85..4d744ad 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.1.0-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -108,7 +108,7 @@ The function accepts the following arguments: - - - - From c525e0c2c5c813ec9d2bfeabe2cc289ea0eabf39 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:33:58 +0000 Subject: [PATCH 015/115] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 458 -- test/test.js | 458 -- 54 files changed, 6202 insertions(+), 5893 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5c0cc24..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:29:25.229Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 88f4201..cfa4705 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bfe1dee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index b32b5cf..36f601b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..00b0a7e --- /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 a9ebdbc..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 36294f975693021b328e265f1cacacc22930a9c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:09:50 +0000 Subject: [PATCH 016/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3910c48..87633f2 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0465233a00aa4eccccdc41131fb09c5bc6735824 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:22:05 +0000 Subject: [PATCH 017/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 cfa4705..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bfe1dee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00b0a7e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4d6e2655e50722bedf24d802749e84a067b684ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:23:08 +0000 Subject: [PATCH 018/115] 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 | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 458 -- test/test.js | 458 -- 53 files changed, 6202 insertions(+), 5892 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 88f4201..cfa4705 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9d0faf9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 87633f2..36f601b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..e9035dd --- /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 a9ebdbc..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From e563a66106b45b8df9601fcee1739fbc5a76ec94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:53:14 +0000 Subject: [PATCH 019/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 42340a9..6a0c3b4 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From de999ba84f1195b80c7db606e5094cdbc27b322d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:30:02 +0000 Subject: [PATCH 020/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 cfa4705..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d0faf9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e9035dd..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7b3acba0c18f47ba64a6f6f1dd722e238ff87d31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:30:52 +0000 Subject: [PATCH 021/115] 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 | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 54 files changed, 6202 insertions(+), 5476 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 54161dc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:49:30.419Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 88f4201..cfa4705 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9d0faf9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 6a0c3b4..36f601b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..4c9389c --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From e6cd02d4f1cd1400c7ae7b1aae6730a4a4415749 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 11:22:23 +0000 Subject: [PATCH 022/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8b03049..1c4ca69 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2dc0d81e810deb70de466acb20fe76b666ca7279 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 15:11:33 +0000 Subject: [PATCH 023/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 cfa4705..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d0faf9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4c9389c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ebeb7175084aabb5a1acbd6c412ad2343a1f1008 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 15:12:12 +0000 Subject: [PATCH 024/115] 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 | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 53 files changed, 6202 insertions(+), 5475 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 166b563..7185b27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9d0faf9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 1c4ca69..36f601b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..5d06860 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 7f45b7cf9ef388fa5984539f711f23137560fdb4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Nov 2023 19:41:08 +0000 Subject: [PATCH 025/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d95384d..4261bce 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From fcbfccbae1dac8cf5c4fda13c699c41353738315 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Nov 2023 19:41:37 +0000 Subject: [PATCH 026/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 7185b27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; unified-signatures - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d0faf9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5d06860..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1f60d130d3a83bdc2f0b50aa0480960a5d03ba0f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Nov 2023 19:42:21 +0000 Subject: [PATCH 027/115] 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 | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 53 files changed, 6202 insertions(+), 5475 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9d0faf9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 4261bce..36f601b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..723d2d5 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From bf82448d0f241648dd5b10c041649084364ca861 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Nov 2023 00:34:16 +0000 Subject: [PATCH 028/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6071956..44809b0 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eea08e2ba1dbd3255fad3795a941b775afc0cb99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Nov 2023 00:34:43 +0000 Subject: [PATCH 029/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d0faf9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 723d2d5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fa93e5f8638fb93440659052b67f5730da479ac6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Nov 2023 00:35:34 +0000 Subject: [PATCH 030/115] 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 | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 53 files changed, 6202 insertions(+), 5475 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9d0faf9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 44809b0..b6e0f13 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..4d7cde2 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From da5e61f8adcf2417571c050cd267cd5d948911ee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Nov 2023 00:36:01 +0000 Subject: [PATCH 031/115] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 872bf3d..bb0f831 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.1.1-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -108,7 +108,7 @@ The function accepts the following arguments: - - - - From dd54e5139acbf5ba43ad296e22ef80c295c5023b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:11:38 +0000 Subject: [PATCH 035/115] 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 | 39 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 54 files changed, 6202 insertions(+), 5471 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e57d050..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:54:00.910Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 e727778..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 078b69f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 11ac56d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f20f60a..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 954248b..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index e6ef4f3..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a06f55e..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 17bcb5a..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index d3a3d03..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c8c121c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 314e4a4..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index c102579..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index f46121e..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e1464f5..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9d0faf9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 44809b0..b6e0f13 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..ca16912 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 5a0301894428d5a1e639bef739a86fc5a7b18bd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:19:41 +0000 Subject: [PATCH 036/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index de2f259..efdd51d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 230f16de58d606b2f2d3007157b2f1e770edd05e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:59:47 +0000 Subject: [PATCH 037/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d0faf9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ca16912..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f946213b1ad06436ad352d1d4c6d0df0e5e4e652 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:00:15 +0000 Subject: [PATCH 038/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 55 files changed, 6202 insertions(+), 5477 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d59911b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:22:45.945Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 03ea217..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA 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 + + ```
@@ -162,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -222,9 +215,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c42385..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/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..790f52e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index efdd51d..b6e0f13 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..553a078 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 683f990c2f34254803911512f348d7b6ec1a12e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:53:58 +0000 Subject: [PATCH 039/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index de2f259..efdd51d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e41b9f3ab5392f748bb664815124a3b45a376904 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:15:16 +0000 Subject: [PATCH 040/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 790f52e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 553a078..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 457b620bbc78fa7d1764632314f8c73e249bc65a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:15:32 +0000 Subject: [PATCH 041/115] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 55 files changed, 6202 insertions(+), 5482 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c1640eb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:14:27.580Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 03ea217..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..790f52e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index efdd51d..b6e0f13 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..a49b96c --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 613ec8115c547d1c7bde041b6d47caccc44248f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 00:58:25 +0000 Subject: [PATCH 042/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c3bf95f..c629d0c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.0", "@stdlib/ndarray-base-shape2strides": "^0.2.0", "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a1fe3f0373293fcf99767d79d02bf6ebfdae8d58 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:14:52 +0000 Subject: [PATCH 043/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 790f52e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a49b96c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 150491ccf2778ba079518317545e5e9c2d31b584 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:15:25 +0000 Subject: [PATCH 044/115] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 54 files changed, 6202 insertions(+), 5485 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 484b045..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ffa9f01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.0-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index c629d0c..8b55b23 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.0", - "@stdlib/ndarray-base-ctor": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.0", - "@stdlib/ndarray-base-shape2strides": "^0.2.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.2.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-int16": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-int8": "^0.2.0", - "@stdlib/array-uint16": "^0.2.0", - "@stdlib/array-uint32": "^0.2.0", - "@stdlib/array-uint8": "^0.2.0", - "@stdlib/array-uint8c": "^0.2.0", - "@stdlib/assert-instance-of": "^0.2.0", - "@stdlib/assert-is-ndarray-like": "^0.2.0", - "@stdlib/buffer-ctor": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/ndarray-dtypes": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..5e13c98 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 32b5cc63cc5b3e890d98de79e70915521195ffa1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:12:08 +0000 Subject: [PATCH 045/115] 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 d4d5203..1ea24e3 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.2.0-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -108,7 +108,7 @@ The function accepts the following arguments: - - - - From d16a2afcb75057ac49786408e8639db938d919b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:48:47 +0000 Subject: [PATCH 049/115] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 54 files changed, 4867 insertions(+), 5479 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..594564c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index f373f83..1a22b23 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..8ffc2bb --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From e003bf7d8470dfb8a8dc9998820c8da87a7eebd4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:30:13 +0000 Subject: [PATCH 050/115] 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 214f60b..a189104 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.2.1-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -108,7 +108,7 @@ The function accepts the following arguments: - - - - From 100f7a9f9cb9e425fe29ed06ac73265779da0d74 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:54:03 +0000 Subject: [PATCH 054/115] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 55 files changed, 4867 insertions(+), 5481 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8999a46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T05:54:34.486Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65ea7d3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 6372dfd..1a22b23 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..9b6bf34 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From dd1216e6bc90da5fce212095b6675fc68026a35e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:28:50 +0000 Subject: [PATCH 055/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f1e3c00..6372dfd 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.1", "@stdlib/ndarray-base-shape2strides": "^0.2.1", "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d051dc4f618e25d2d59036c5b2e0016a7015ca12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:53:21 +0000 Subject: [PATCH 056/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65ea7d3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9b6bf34..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c025a7e5ac3c29248a7f8a65497a285a7ce870e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:53:38 +0000 Subject: [PATCH 057/115] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 55 files changed, 4867 insertions(+), 5484 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b1ab72a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:11:35.985Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65ea7d3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 6372dfd..1a22b23 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..9b6bf34 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From d57207e20530a2de19df04491ed122ec5d0fef0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:43:57 +0000 Subject: [PATCH 058/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f1e3c00..6372dfd 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.1", "@stdlib/ndarray-base-shape2strides": "^0.2.1", "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b0dd556ff46f7f7b6235ed125db508c1fe6937bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:08:05 +0000 Subject: [PATCH 059/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65ea7d3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9b6bf34..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9580ff2ada7fc5187e7b64dca162b2f5bd852fdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:08:21 +0000 Subject: [PATCH 060/115] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 458 -- 54 files changed, 4867 insertions(+), 5485 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 c6cbca0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5df0948..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index e54c503..98f8ef4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65ea7d3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 6372dfd..1a22b23 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -99,4 +29,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..9b6bf34 --- /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 57d75c8..0000000 --- a/test/test.js +++ /dev/null @@ -1,458 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 58c158390643f2eb419879d6cf627603c22dae55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:32:33 +0000 Subject: [PATCH 061/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 017dc55..fb42edf 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.1", "@stdlib/ndarray-base-shape2strides": "^0.2.1", "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-bool": "^0.0.1", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cc47474009e2448f60aa53d8af39dc26523b7ff2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:33:33 +0000 Subject: [PATCH 062/115] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 98f8ef4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65ea7d3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9b6bf34..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ba9fc094512fa2a0d44c185ada5e404db01a54b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:33:48 +0000 Subject: [PATCH 063/115] 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 | 122 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 -- benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 485 --- 55 files changed, 4867 insertions(+), 5754 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 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 d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65ea7d3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index fb42edf..1a22b23 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -100,4 +29,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..9b6bf34 --- /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 e4c9ea5..0000000 --- a/test/test.js +++ /dev/null @@ -1,485 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From b7837fa11afac1900e8976f24758c7d8b234dd6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:10:41 +0000 Subject: [PATCH 064/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e62f371..0a1116c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.0.1", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3b78059c1dc2b40a36ef8bcb7d08d28b88f38f93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:33:18 +0000 Subject: [PATCH 065/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65ea7d3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9b6bf34..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 959c860d94ba3d8b9b7066584a69547f47924937 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:33:37 +0000 Subject: [PATCH 066/115] 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 | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 217 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 -- benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 485 --- 55 files changed, 4867 insertions(+), 5851 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 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 d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..12684df --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 0a1116c..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -100,4 +29,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..899e0ed --- /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 e4c9ea5..0000000 --- a/test/test.js +++ /dev/null @@ -1,485 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 5d0eb87786acd41840fdddbf95dbe96b18fe9e3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:44:28 +0000 Subject: [PATCH 067/115] 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 8bde2c6..5b109fd 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.3.0-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -108,7 +108,7 @@ The function accepts the following arguments: - - - - From 1696fdcd7f49562f5c66fc1c79f771634b858630 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:12:38 +0000 Subject: [PATCH 071/115] 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 | 98 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 -- benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 485 --- 56 files changed, 4867 insertions(+), 5733 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 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 8497422..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T06:04:26.628Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0c21bfb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index bb349d1..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -100,4 +29,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..bb7c4a2 --- /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 e4c9ea5..0000000 --- a/test/test.js +++ /dev/null @@ -1,485 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 1b4e4f0530af6b03f42193c9c93eae0ab3504027 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:41:34 +0000 Subject: [PATCH 072/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7c4d693..9a242f6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ed8e90e72545491a7fade4ffdc605ce140c4d62d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:12:32 +0000 Subject: [PATCH 073/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0c21bfb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bb7c4a2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7a7041e921e616879362af86c62fa144e58a60df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:12:52 +0000 Subject: [PATCH 074/115] 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 | 216 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 -- benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 77 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 485 --- 56 files changed, 4867 insertions(+), 5851 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 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 faa76fd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:32:15.740Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0c21bfb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 9a242f6..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -100,4 +29,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..bb7c4a2 --- /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 e4c9ea5..0000000 --- a/test/test.js +++ /dev/null @@ -1,485 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From e7dd70639513e0f748724040a676c232b37bb481 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 02:05:42 +0000 Subject: [PATCH 075/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d66132a..a4d2fa2 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 09bd6d88a80f5f169dd7b0527aa5f72fc2ed42b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 02:33:43 +0000 Subject: [PATCH 076/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0c21bfb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bb7c4a2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eb7385e9d98b170c29319caca87d208c552fb451 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 02:34:05 +0000 Subject: [PATCH 077/115] 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 | 216 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 77 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 485 -- 57 files changed, 4867 insertions(+), 5956 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0877aba..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T01:57:46.880Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d3540ba..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0c21bfb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index a4d2fa2..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -100,4 +29,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..bb7c4a2 --- /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 e4c9ea5..0000000 --- a/test/test.js +++ /dev/null @@ -1,485 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From f3a3fa3b86c8d30016cd5e4a5545b8503aecf8ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:50:12 +0000 Subject: [PATCH 078/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d66132a..a4d2fa2 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bcb09351adb2f610fb55e71a504dff6fc74c166b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:41:27 +0000 Subject: [PATCH 079/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0c21bfb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bb7c4a2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8b1f1583d3b4c1260dd05866c8f509f79e3b460a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:41:51 +0000 Subject: [PATCH 080/115] 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 | 216 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 40 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 77 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 485 -- 57 files changed, 4867 insertions(+), 5959 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f3db369..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:35:47.302Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +155,7 @@ for ( i = 0; i < dt.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]. @@ -227,9 +218,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 056a034..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(g,n){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-ctor/dist'),c=require('@stdlib/ndarray-base-numel/dist'),o=require('@stdlib/array-empty/dist'),y=require('@stdlib/buffer-alloc-unsafe/dist');function b(e,r,t){var u,s,i,a;return u=r.length,u>0?(i=c(r),a=l(r,t)):(i=1,a=[0]),e==="binary"?s=y(i):s=o(i,e),new m(e,s,r,a,q(r,a),t)}n.exports=b -});var x=v();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index fff6394..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EAwBzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKL,CAAM,EAEvB,IAAIL,EAASK,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5d8c63d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 26cebb4..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65223fd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..927b583 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 679d44a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7d2e671..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index a4d2fa2..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -100,4 +29,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..bb7c4a2 --- /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 e4c9ea5..0000000 --- a/test/test.js +++ /dev/null @@ -1,485 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); From 2d58192118518a5c1facd172e25f9ff981b135b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 20:38:33 +0000 Subject: [PATCH 081/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 463c12d..aef3419 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ad10d09699fb5df7bc5ac343632240a516a96123 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 20:38:52 +0000 Subject: [PATCH 082/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65223fd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function i(i,m,a){var j,l,o;return m.length>0?(l=r(m),o=s(m,a)):(l=1,o=[0]),j="binary"===i?n(l):d(l,i),new t(i,j,m,o,e(m,o),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 927b583..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","length","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;wjBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAgBJ,OAdQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACES,EAAaL,GAEbM,EAAYN,EAAKJ,GAEjB,IAAIW,EAASX,EAAOG,EAAKF,EAAOI,EAAIO,EAAgBX,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bb7c4a2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 19622e89b5ee12397dbfd22da3f8a281e8aa0889 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 20:39:20 +0000 Subject: [PATCH 083/115] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 251 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 82 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 56 files changed, 4869 insertions(+), 6017 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -167,7 +158,7 @@ for ( i = 0; i < dt.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]. @@ -230,9 +221,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b5bef2..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 empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ebac981 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index aef3419..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,59 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-shape": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -105,4 +29,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..004d21a --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From b2428374e3eee34b96239b3cb120dff71c2ea23e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 20:48:50 +0000 Subject: [PATCH 084/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 90e6f4c..76f1f4a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -105,4 +106,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From de432f3e40a45a48111af48e16f108ff5e6f52ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 20:49:08 +0000 Subject: [PATCH 085/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ebac981..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 004d21a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b125d69215e125dbdf7c85b8d032a2a8cb1f9cfc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 20:49:40 +0000 Subject: [PATCH 086/115] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 252 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 83 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 56 files changed, 4870 insertions(+), 6021 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ebac981 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 76f1f4a..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-shape": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-to-array": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -106,4 +29,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..004d21a --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From 4e2b0755664280f33d032e0bcdcf62c16e495eb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 06:25:56 +0000 Subject: [PATCH 087/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f53cb2d..f2b2b7c 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.1", @@ -105,4 +106,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b306fdbc664e40249348547da07eb9f6b9420da2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:19:49 +0000 Subject: [PATCH 088/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ebac981..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 004d21a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f59c02906ab8b4c0b6f6f752ddcc3ff8c877c74f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:20:08 +0000 Subject: [PATCH 089/115] 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 | 252 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 83 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 56 files changed, 4870 insertions(+), 6121 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2a44491 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index f2b2b7c..08de085 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.1", - "@stdlib/array-complex128": "^0.3.1", - "@stdlib/array-complex64": "^0.3.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.3.0", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-shape": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.4.0", - "@stdlib/ndarray-to-array": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -106,4 +29,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..004d21a --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From 9a01eb5149e9596cd7fb3b2e94aec958f016728f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 22:50:31 +0000 Subject: [PATCH 090/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9929b2f..0e5a18f 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.3", "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -105,4 +106,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ab31143cd2795a63fcd92c3efc8b8a2f9107d23c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:32:47 +0000 Subject: [PATCH 091/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2a44491..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 004d21a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e0754e80a50b18e3d17525bbf9ffb0a2f412728d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:33:04 +0000 Subject: [PATCH 092/115] 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 | 262 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 83 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 56 files changed, 4870 insertions(+), 6124 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 0e5a18f..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -106,4 +29,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..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From 6d5afddde95434179dceaf5a766727a8fddebf99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:03:48 +0000 Subject: [PATCH 093/115] Update README.md for ESM bundle v0.3.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 95f0e2c..e6216a1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.3.2-esm/index.mjs'; ``` #### empty( dtype, shape, order ) @@ -112,7 +112,7 @@ The function accepts the following arguments: import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.3.2-esm/index.mjs'; // Get a list of data types: var dt = dtypes( 'integer_and_generic' ); From 913ddec27bcf3b857323c09144d74e11a8c83a5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:03:49 +0000 Subject: [PATCH 094/115] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6216a1..3e88f9e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-empty/tags). For example, + ```javascript import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.3.2-esm/index.mjs'; ``` @@ -112,7 +117,7 @@ The function accepts the following arguments: import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; -import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@v0.3.2-esm/index.mjs'; +import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-empty@esm/index.mjs'; // Get a list of data types: var dt = dtypes( 'integer_and_generic' ); From 9981bf0e037f99c8764985045b90e331c8bf54a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Feb 2026 01:48:54 +0000 Subject: [PATCH 095/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bca9ea7..9f9cefb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.3", "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -105,4 +106,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2b9c2a07a7e540a19c77bb200ba1c803ac5dc4bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Feb 2026 03:09:54 +0000 Subject: [PATCH 096/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1da2ba9b5b7644ad9fc45ec1e140ec5e2532ffb4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Feb 2026 03:10:18 +0000 Subject: [PATCH 097/115] 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 | 262 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 83 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 57 files changed, 4870 insertions(+), 6125 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9e2c89e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-23T01:26:27.578Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 9f9cefb..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -106,4 +29,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..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From 8c501a81b4be488db9acb02e1438ba9b85bf6c3e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Apr 2026 03:57:35 +0000 Subject: [PATCH 098/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bca9ea7..9f9cefb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.3", "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -105,4 +106,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1c94fc8b8a572379737c2db245f2dd35552d3dd7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Apr 2026 04:07:33 +0000 Subject: [PATCH 099/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bad0b00324774c55bc04faa95af3e6c117dd537f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Apr 2026 04:07:52 +0000 Subject: [PATCH 100/115] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 262 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 83 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 57 files changed, 4870 insertions(+), 6136 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 86c225d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-08T03:46:43.854Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 9f9cefb..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -106,4 +29,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..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From cf93a8c74f82b2346f016c4a95f048c24906b20c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 16 May 2026 03:45:14 +0000 Subject: [PATCH 101/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bca9ea7..9f9cefb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/ndarray-base-numel": "^0.2.3", "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -105,4 +106,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 329ed2a1d1093abc8c07f11c7c43dec555b60cd1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 16 May 2026 03:57:54 +0000 Subject: [PATCH 102/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5d4785068c1a37a6b8db824f4690c630e558404f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 16 May 2026 03:58:15 +0000 Subject: [PATCH 103/115] 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 | 262 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.bool.js | 93 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 83 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 57 files changed, 4870 insertions(+), 6141 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8cf69b7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-16T03:42:15.137Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 6450e34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 28b4935..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index f74522e..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 868544b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 60733b1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index b37f0b2..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 7eaa405..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 48b28aa..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cb9bf8b..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 9c56b2c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 7b283fd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b086755..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 0c3c0a2..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 63d9d13..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 9f9cefb..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -106,4 +29,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..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From f90e78981192b39bee950e938da6c4a09f8791bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 May 2026 10:53:57 +0000 Subject: [PATCH 104/115] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3a4fd3e..46f5fa8 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@stdlib/ndarray-base-shape": "^0.2.3", "@stdlib/ndarray-dtypes": "^0.4.1", "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From f8ca5ac344569090c80952c5bee543dba0b24db4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 May 2026 10:54:47 +0000 Subject: [PATCH 105/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d7692324378a0c3e74d1fcfc78c6a5daeec8ba58 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 May 2026 10:55:10 +0000 Subject: [PATCH 106/115] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 296 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.bool.js | 94 - benchmark/benchmark.size.complex128.js | 94 - benchmark/benchmark.size.complex64.js | 94 - benchmark/benchmark.size.float32.js | 94 - benchmark/benchmark.size.float64.js | 94 - benchmark/benchmark.size.generic.js | 94 - benchmark/benchmark.size.int16.js | 94 - benchmark/benchmark.size.int32.js | 94 - benchmark/benchmark.size.int8.js | 94 - benchmark/benchmark.size.uint16.js | 94 - benchmark/benchmark.size.uint32.js | 94 - benchmark/benchmark.size.uint8.js | 94 - benchmark/benchmark.size.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 81 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 56 files changed, 4869 insertions(+), 6187 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 66386d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 3136602..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=bool,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 1bbe245..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex128,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 5c8df29..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 2223920..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 5d3b93a..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 46fba43..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=generic,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 31ed93e..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 2ab0b37..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 4e87b28..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 99b9987..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 704759b..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index ebdc32d..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 2d53e5b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8c,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 46f5fa8..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From 36e87565879a4eded8f289ac38478925a700072e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 May 2026 03:50:16 +0000 Subject: [PATCH 107/115] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3a4fd3e..46f5fa8 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@stdlib/ndarray-base-shape": "^0.2.3", "@stdlib/ndarray-dtypes": "^0.4.1", "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From dd18e31757879ebdafd640425458ac911f0735d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 May 2026 04:01:59 +0000 Subject: [PATCH 108/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 50601f1e531882902ae2f3cf3afc70a62d1411fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 May 2026 04:02:20 +0000 Subject: [PATCH 109/115] 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 | 296 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.bool.js | 94 - benchmark/benchmark.size.complex128.js | 94 - benchmark/benchmark.size.complex64.js | 94 - benchmark/benchmark.size.float32.js | 94 - benchmark/benchmark.size.float64.js | 94 - benchmark/benchmark.size.generic.js | 94 - benchmark/benchmark.size.int16.js | 94 - benchmark/benchmark.size.int32.js | 94 - benchmark/benchmark.size.int8.js | 94 - benchmark/benchmark.size.uint16.js | 94 - benchmark/benchmark.size.uint32.js | 94 - benchmark/benchmark.size.uint8.js | 94 - benchmark/benchmark.size.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 81 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 57 files changed, 4869 insertions(+), 6188 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9f52783..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-19T03:45:13.667Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 66386d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 3136602..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=bool,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 1bbe245..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex128,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 5c8df29..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 2223920..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 5d3b93a..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 46fba43..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=generic,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 31ed93e..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 2ab0b37..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 4e87b28..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 99b9987..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 704759b..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index ebdc32d..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 2d53e5b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8c,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8a3f175..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,u){var v,t,i,a,s;return v=r.length,v>0?(i=y(r),a=f(r,u)):(i=1,a=[0]),s=o(e),s==="binary"?t=b(i):t=d(i,s),new c(e,t,r,a,m(r,a),u)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b0052b0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 46f5fa8..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From 7a8b426adcf0f566e87a151cc22cc09f50e7689a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jun 2026 03:58:50 +0000 Subject: [PATCH 110/115] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69af63f..83a9ea0 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@stdlib/ndarray-base-shape": "^0.2.3", "@stdlib/ndarray-dtypes": "^0.4.1", "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From a449d06c821113364dcf75769075aabb090d5d94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jun 2026 04:06:51 +0000 Subject: [PATCH 111/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e8040edd21166c975f27f8145b3e338a03345d6c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jun 2026 04:07:12 +0000 Subject: [PATCH 112/115] 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 | 296 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.bool.js | 94 - benchmark/benchmark.size.complex128.js | 94 - benchmark/benchmark.size.complex64.js | 94 - benchmark/benchmark.size.float32.js | 94 - benchmark/benchmark.size.float64.js | 94 - benchmark/benchmark.size.generic.js | 94 - benchmark/benchmark.size.int16.js | 94 - benchmark/benchmark.size.int32.js | 94 - benchmark/benchmark.size.int8.js | 94 - benchmark/benchmark.size.uint16.js | 94 - benchmark/benchmark.size.uint32.js | 94 - benchmark/benchmark.size.uint8.js | 94 - benchmark/benchmark.size.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 81 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 57 files changed, 4869 insertions(+), 6201 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c624bec..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-29T03:55:05.266Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 66386d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 3136602..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=bool,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 1bbe245..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex128,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 5c8df29..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 2223920..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 5d3b93a..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 46fba43..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=generic,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 31ed93e..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 2ab0b37..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 4e87b28..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 99b9987..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 704759b..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index ebdc32d..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 2d53e5b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8c,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 42422eb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(i){throw (r=0, i)}};};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,i){var v,s,a,t,u;return v=r.length,v>0?(a=y(r),t=f(r,i)):(a=1,t=[0]),u=o(e),u==="binary"?s=b(a):s=d(a,u),new c(e,s,r,t,m(r,t),i)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 98aa776..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 83a9ea0..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); From f29cdc4559b6790fe4125e2f27d8b09e202b521d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Aug 2026 03:10:45 +0000 Subject: [PATCH 113/115] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69af63f..83a9ea0 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@stdlib/ndarray-base-shape": "^0.2.3", "@stdlib/ndarray-dtypes": "^0.4.1", "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From fc8c6ea008b16f6156c9667d7fef4d579bf80d5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Aug 2026 03:18:24 +0000 Subject: [PATCH 114/115] Remove files --- index.d.ts | 308 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5155 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 0c0d8b2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,308 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function empty( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function empty( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function empty( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function empty( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function empty( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function empty( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function empty( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function empty( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function empty( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function empty( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'bool', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'bool' -*/ -declare function empty( dtype: 'bool', shape: Shape, order: Order ): boolndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function empty( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates an uninitialized array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns output array -* -* @example -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function empty( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = empty; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d5035e5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3dc10fb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a3433..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 82a675427bded263aa66b08f004e6b2b85d39804 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Aug 2026 03:18:48 +0000 Subject: [PATCH 115/115] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 296 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.bool.js | 94 - benchmark/benchmark.size.complex128.js | 94 - benchmark/benchmark.size.complex64.js | 94 - benchmark/benchmark.size.float32.js | 94 - benchmark/benchmark.size.float64.js | 94 - benchmark/benchmark.size.generic.js | 94 - benchmark/benchmark.size.int16.js | 94 - benchmark/benchmark.size.int32.js | 94 - benchmark/benchmark.size.int8.js | 94 - benchmark/benchmark.size.uint16.js | 94 - benchmark/benchmark.size.uint32.js | 94 - benchmark/benchmark.size.uint8.js | 94 - benchmark/benchmark.size.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 38 - docs/types/test.ts | 96 - examples/index.js | 34 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 86 - package.json | 81 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 489 -- 57 files changed, 4869 insertions(+), 6202 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 085cad6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-18T03:09:08.235Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a2699f2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 6de5d34..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty) 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 5ba0653..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: '32 8 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < dt.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]. @@ -231,9 +222,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-empty/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 66386d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 3136602..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'bool', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=bool,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 1bbe245..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex128,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index 5c8df29..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=complex64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 2223920..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 5d3b93a..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=float64,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 46fba43..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=generic,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 31ed93e..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 2ab0b37..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 4e87b28..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=int8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 99b9987..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint16,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 704759b..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint32,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index ebdc32d..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 2d53e5b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:dtype=uint8c,size=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51609cb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty" -%% click B href "https://github.com/stdlib-js/ndarray-base-empty/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-empty/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-empty/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-empty/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-empty/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/empty -[production-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-empty/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-empty/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-empty/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 8f04474..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import empty from '../docs/types/index'; -export = empty; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 42422eb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(i){throw (r=0, i)}};};var l=q(function(A,n){ -var f=require('@stdlib/ndarray-base-shape2strides/dist'),m=require('@stdlib/ndarray-base-strides2offset/dist'),o=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/array-empty/dist'),b=require('@stdlib/buffer-alloc-unsafe/dist');function x(e,r,i){var v,s,a,t,u;return v=r.length,v>0?(a=y(r),t=f(r,i)):(a=1,t=[0]),u=o(e),u==="binary"?s=b(a):s=d(a,u),new c(e,s,r,t,m(r,t),i)}n.exports=x -});var g=l();module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 98aa776..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = empty;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-base-empty\n*\n* @example\n* var getShape = require( '@stdlib/ndarray-shape' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var empty = require( '@stdlib/ndarray-base-empty' );\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAa,QAAS,wCAAyC,EAC/DC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EA2BzD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,OAAAJ,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMT,EAAOK,CAAM,EACnBK,EAAKd,EAAeS,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVC,EAAKb,EAAYM,CAAM,EAClBO,IAAO,SACXH,EAAMN,EAAaO,CAAI,EAEvBD,EAAMP,EAAYQ,EAAKE,CAAG,EAIpB,IAAIZ,EAASK,EAAOI,EAAKH,EAAOK,EAAIb,EAAgBQ,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAX,EAAO,QAAUQ,IC3CjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "resolveStr", "ndarray", "numel", "emptyArray", "allocUnsafe", "empty", "dtype", "shape", "order", "ndims", "buf", "len", "st", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 863d321..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns an uninitialized ndarray having a specified shape and data type. - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - dtype: string|DataType - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) - [ 2, 2 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85473a9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - empty( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - empty( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - empty( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - empty( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - empty( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - empty( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - empty( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - empty( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - empty( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - empty( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - empty( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - empty( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - empty( 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray - empty( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - empty( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - empty( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( false, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( true, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( null, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( [], [ 2, 2 ], 'row-major' ); // $ExpectError - empty( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - empty( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - empty( 'float32', '5', 'row-major' ); // $ExpectError - empty( 'float32', false, 'row-major' ); // $ExpectError - empty( 'float32', true, 'row-major' ); // $ExpectError - empty( 'float32', null, 'row-major' ); // $ExpectError - empty( 'float32', undefined, 'row-major' ); // $ExpectError - empty( 'float32', [ '5' ], 'row-major' ); // $ExpectError - empty( 'float32', {}, 'row-major' ); // $ExpectError - empty( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - empty( 'float32', [ 2, 2 ], '5' ); // $ExpectError - empty( 'float32', [ 2, 2 ], false ); // $ExpectError - empty( 'float32', [ 2, 2 ], true ); // $ExpectError - empty( 'float32', [ 2, 2 ], null ); // $ExpectError - empty( 'float32', [ 2, 2 ], undefined ); // $ExpectError - empty( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - empty( 'float32', [ 2, 2 ], {} ); // $ExpectError - empty( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 'float64' ); // $ExpectError - empty( 'float64', [ 2, 2 ] ); // $ExpectError - empty( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8e9acdb..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var empty = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'integer_and_generic' ); - -// Generate uninitialized arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( ndarray2array( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5a6b0f4..0c0d8b2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d5035e5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";function m(m,a,j){var l,o,p,h;return a.length>0?(o=d(a),p=s(a,j)):(o=1,p=[0]),l="binary"===(h=t(m))?i(o):n(o,h),new r(m,l,a,p,e(a,p),j)}export{m as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3dc10fb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having a specified shape and data type.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* import getShape from '@stdlib/ndarray-shape';\n* import getDType from '@stdlib/ndarray-dtype';\n*\n* var arr = empty( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = getShape( arr );\n* // returns [ 2, 2 ]\n*\n* var dt = String( getDType( arr ) );\n* // returns 'float32'\n*/\nfunction empty( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar dt;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tdt = resolveStr( dtype );\n\tif ( dt === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dt );\n\t}\n\t// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default empty;\n"],"names":["empty","dtype","shape","order","buf","len","st","dt","length","numel","shape2strides","resolveStr","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;iqBAuDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EACAC,EAmBJ,OAjBQL,EAAMM,OACD,GACZH,EAAMI,EAAOP,GACbI,EAAKI,EAAeR,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAIPF,EADW,YADZG,EAAKI,EAAYV,IAEVW,EAAaP,GAEbQ,EAAYR,EAAKE,GAIjB,IAAIO,EAASb,EAAOG,EAAKF,EAAOI,EAAIS,EAAgBb,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b049ec2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-base-empty -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var empty = require( '@stdlib/ndarray-base-empty' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 16d2ed9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having a specified shape and data type. -* -* @param {*} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var getShape = require( '@stdlib/ndarray-shape' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = empty( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = getShape( arr ); -* // returns [ 2, 2 ] -* -* var dt = String( getDType( arr ) ); -* // returns 'float32' -*/ -function empty( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - var dt; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - dt = resolveStr( dtype ); - if ( dt === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dt ); - } - // FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer. - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = empty; diff --git a/package.json b/package.json index 83a9ea0..afc4c6e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.2", "description": "Create an uninitialized ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,60 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/buffer-ctor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..83a3433 --- /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 e84493b..0000000 --- a/test/test.js +++ /dev/null @@ -1,489 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'binary', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=row-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, order=column-major)', function test( t ) { - var arr; - - arr = empty( 'bool', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = empty( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var arr; - - arr = empty( 'float64', [], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = empty( 'float64', [ 2, 0, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); - t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); - t.deepEqual( getData( arr ), expected, 'returns expected value' ); - t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); - - t.end(); -});